import 'package:flutter/cupertino.dart';
import 'package:flutter_video_app/common/constants/message.dart';
import 'package:flutter_video_app/common/utils/toast_utils.dart';
import 'package:flutter_video_app/navigation/tab_page_view.dart';

//导航栏
class TabNavigation extends StatelessWidget {

  DateTime lastTime;
  @override
  Widget build(BuildContext context) {
    return new WillPopScope(child: TabPageView(), onWillPop: _onWillPop);
  }

  Future<bool> _onWillPop() async{
    var now = DateTime.now();
    if (lastTime == null || now.difference(lastTime) > Duration(seconds: 2)) {
      lastTime=now;
      ToastUtils.showTip(Message.tip_exits);
      return false;
    } else {
      return true;
    }
  }
}
